<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--公司数据-->
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input
            v-model="deptName"
            placeholder="请输入部门名称"
            clearable
            size="default"
            prefix-icon="el-icon-search"
            style="margin-bottom: 20px"
          />
        </div>
        <div class="head-container">
          <el-tree
            :data="orgOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            default-expand-all
            @node-click="handleNodeClick"
          >
            <template #default="{ node, data }">
              <span v-if="data.params.type === 'C'">
                <b>{{ node.label }}</b>
                <el-tag type="info" size="default" class="ml10">公司</el-tag>
              </span>
              <span v-else>{{ node.label }}</span>
            </template>
            <!-- <span slot-scope="{ node, data }">
              <span v-if="data.params.type === 'C'">
                <b>{{ node.label }}</b>
                <el-tag type="info" size="mini" class="ml10">公司</el-tag>
              </span>
              <span v-else>{{ node.label }}</span>
            </span> -->
          </el-tree>
        </div>
      </el-col>
      <!--用户数据-->
      <el-col :span="20" :xs="24">
        <el-form
          :model="queryParams"
          ref="queryForm"
          :inline="true"
          v-show="showSearch"
          label-width="68px"
        >
          <el-form-item label="登录账号" prop="loginName">
            <el-input
              v-model="queryParams.loginName"
              placeholder="请输入要查询的登录名"
              clearable
              size="default"
              style="width: 240px"
              @keyup.enter="handleQuery"
            />
          </el-form-item>
          <el-form-item label="用户名称" prop="userName">
            <el-input
              v-model="queryParams.userName"
              placeholder="请输入用户名称"
              clearable
              size="default"
              style="width: 240px"
              @keyup.enter="handleQuery"
            />
          </el-form-item>
          <!-- <el-form-item label="手机号码" prop="phonenumber">
                          <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable size="small" style="width: 240px" maxlength="11"
                            @keyup.enter.native="handleQuery" />
                        </el-form-item> -->
          <el-form-item label="状态" prop="status">
            <el-select
              v-model="queryParams.status"
              placeholder="用户状态"
              clearable
              size="default"
              style="width: 240px"
            >
              <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="修改时间">
            <el-date-picker
              v-model="dateRange"
              size="default"
              style="width: 240px"
              value-format="YYYY-MM-DD"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            />
          </el-form-item>
          <el-form-item>
            <search-button @click="handleQuery" :perm="['system:user:search']" />
            <reset-button @click="resetQuery" :perm="['system:user:search']" />
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <add-button @click="handleAdd" :perm="['system:user:insert']" />
          <delete-button
            @click="handleDelete"
            :disabled="multiple"
            :perm="['system:user:delete']"
          />
          <import-button @click="handleImport" :perm="['system:user:import']" />
          <export-button @click="handleExport" :perm="['system:user:export']" />
          <right-toolbar
            v-model:showSearch="showSearch"
            @query-table="getList"
            :perm="['system:user:search']"
          />
        </el-row>

        <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="用户ID" min-width="120" align="center" prop="userId" />
          <el-table-column
            label="登录账号"
            min-width="160"
            align="center"
            prop="loginName"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="用户名称"
            min-width="160"
            align="center"
            prop="userName"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="公司/部门"
            min-width="180"
            align="center"
            prop="companyName"
            :show-overflow-tooltip="true"
          >
            <template #default="scope">
              {{ (scope.row.companyName || '-') + ' / ' + (scope.row.deptName || '-') }}
            </template>
          </el-table-column>
          <!-- <el-table-column label="手机号码" align="center" prop="phonenumber" width="130" />
            <el-table-column label="邮箱" align="center" prop="email" width="160" /> -->
          <el-table-column label="状态" align="center" width="100">
            <template #default="scope">
              <el-popover
                v-if="scope.row.status === '2'"
                placement="top-start"
                width="240"
                trigger="hover"
                title="用户已锁定"
                :content="showUserStatusText(scope)"
              >
                <template #reference>
                  <el-tag type="warning">锁定</el-tag>
                </template>
              </el-popover>
              <el-tag
                v-else
                :type="scope.row.status === '0' ? 'success' : 'danger'"
                disable-transitions
              >{{ scope.row.status === '0' ? '正常' : '禁用' }}</el-tag
              >
            </template>
          </el-table-column>
          <el-table-column label="用户密码到期时间" align="center" prop="updatePwdTime" width="160">
            <template v-slot="{ row }">
              <span :style="getExpiryStyle(row.updatePwdTime)">
                {{ row.updatePwdTime || '未设置' }}
              </span>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
          <el-table-column label="修改时间" align="center" prop="updateTime" width="160" />
          <ExtColTableColumn tableName="sys_user" />
          <el-table-column
            label="操作"
            align="center"
            width="260"
            class-name="small-padding fixed-width"
          >
            <template #default="scope">
              <text-disable-button
                v-if="scope.row.status === '0'"
                @click="handleStatusChange(scope.row)"
                :perm="['system:user:update']"
                :title="'是否确认禁用用户' + scope.row.loginName"
              />
              <text-enable-button
                v-else-if="scope.row.status === '1'"
                @click="handleStatusChange(scope.row)"
                :perm="['system:user:update']"
                :title="'是否确认启用用户' + scope.row.loginName"
              />
              <el-popconfirm
                v-else
                :title="'是否确认解锁用户' + scope.row.loginName"
                @on-confirm="handleStatusChange(scope.row)"
                @confirm="handleStatusChange(scope.row)"
              >
                <template #reference>
                  <el-button
                    size="small"
                    type="primary"
                    link
                    icon="Unlock"
                    v-hasPermi="['system:user:update']"
                  >解锁
                  </el-button>
                </template>
              </el-popconfirm>
              <text-edit-button @click="handleUpdate(scope.row)" :perm="['system:user:update']" />
              <text-delete-button
                @click="handleDelete(scope.row)"
                :perm="['system:user:delete']"
                :title="'是否确认删除用户' + scope.row.loginName + '?'"
              />
              <el-button
                size="small"
                type="primary"
                link
                icon="Key"
                @click="handleResetPwd(scope.row)"
                v-hasPermi="['system:user:resetPwd']"
              >重置</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <!-- 添加或修改参数配置对话框 -->
    <drag-dialog
      :title="title"
      :close-on-click-modal="false"
      v-model="open"
      width="800px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="登录账号" prop="loginName">
              <el-input
                :disabled="form.userId != undefined"
                v-model="form.loginName"
                placeholder="请输入登录账号"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
              <el-input
                v-model="form.password"
                placeholder="请输入用户密码"
                type="password"
                show-password
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户名称" prop="userName">
              <el-input v-model="form.userName" placeholder="请输入用户名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="归属部门" prop="selectedOrgId">
              <el-tree-select
                v-model="form.selectedOrgId"
                :data="orgOptions"
                :props="{ children: 'children', label: 'name', value: 'id' }"
                check-strictly
                :load="loadOptions" 
                :render-after-expand="true"
                :default-expand-all="false" 
                placeholder="请选择归属公司或部门"
                @node-click="selectOrgNode"
                :filterable="true"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="手机号码" prop="phonenumber">
              <el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="用户性别">
              <el-select
                v-model="form.sex"
                placeholder="请选择"
                :clearable="true"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in sexOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态">
              <el-radio-group v-model="form.status">
                <el-radio
                  v-for="dict in statusOptions"
                  :key="dict.dictValue"
                  :value="dict.dictValue"
                >{{ dict.dictLabel }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="岗位">
              <el-select
                v-model="form.postIds"
                multiple
                placeholder="请选择"
                :clearable="true"
                style="width: 100%"
              >
                <el-option
                  v-for="item in postOptions"
                  :key="parseInt(item.postId)"
                  :label="item.postName"
                  :value="parseInt(item.postId)"
                  :disabled="item.status == 1"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="角色">
              <el-select
                v-model="form.roleIds"
                multiple
                placeholder="请选择"
                :clearable="true"
                style="width: 100%"
              >
                <el-option
                  v-for="item in roleOptions"
                  :key="parseInt(item.roleId)"
                  :label="item.roleName"
                  :value="parseInt(item.roleId)"
                  :disabled="item.status == 1"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <ExtColFormItem tableName="sys_user" :form="form" :span="12" />
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <dialog-footer @ok="submitForm" @cancel="cancel" />
      </template>
    </drag-dialog>

    <!-- 用户导入对话框 -->
    <drag-dialog
      :title="upload.title"
      :close-on-click-modal="false"
      v-model="upload.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <el-icon class="el-icon--upload"><upload-filled /></el-icon>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <template #tip>
          <div class="el-upload__tip">
            <el-link type="primary" style="font-size: 12px" @click="handleImportTemplate">下载模板</el-link>
            <div class="el-upload__tip" style="color: red">
              提示：仅允许导入“xls”或“xlsx”格式文件！
            </div>
          </div>
        </template>
      </el-upload>
      <template #footer>
        <dialog-footer @ok="submitFileForm" @cancel="upload.open = false" />
      </template>
    </drag-dialog>
  </div>
</template>

<script>
import {
  listPage,
  getUser,
  delUser,
  addUser,
  updateUser,
  exportUser,
  resetUserPwd,
  changeUserStatus,
  isLoginNameExist,
  isPhoneNumberExist,
  isEmailExist,
  orgTreeList
} from '@base/api/base/user'
import { getToken } from '@/utils/auth'
import defaultSettings from '@/settings'
import { debounceWrapper } from '@/utils/zmids'

export default {
  name: 'BaseUser',
  data() {
    const isLoginNameExistRule = (rule, value, callback) => {
      if (this.form.userId === undefined && value) {
        isLoginNameExist(value).then((response) => {
          if (response.data === true) {
            callback('登录名已存在')
          } else {
            callback()
          }
        })
      } else {
        // 编辑的时候不校验
        callback()
      }
    }
    const isPhoneNumberExistRule = (rule, value, callback) => {
      if (value) {
        isPhoneNumberExist(value, this.form.userId).then((response) => {
          if (response.data === true) {
            callback('手机号已存在')
          } else {
            callback()
          }
        })
      } else {
        callback()
      }
    }
    const isEmailExistRule = (rule, value, callback) => {
      if (value) {
        isEmailExist(value, this.form.userId).then((response) => {
          if (response.data === true) {
            callback('邮箱已存在')
          } else {
            callback()
          }
        })
      } else {
        callback()
      }
    }
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: '',
      // 公司部门组织树选项
      orgOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      // 日期范围
      dateRange: [],
      // 状态数据字典
      statusOptions: [],
      // 性别状态字典
      sexOptions: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {},
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { [defaultSettings.tokenName]: 'Bearer ' + getToken() },
        // 上传的地址
        url: import.meta.env.VITE_APP_BASE_API + '/system/user/importData'
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        companyId: undefined,
        deptId: undefined
      },
      // 表单校验
      rules: {
        loginName: [
          {
            required: true,
            message: '登录账号不能为空',
            trigger: 'blur'
          },
          {
            min: 1,
            max: 20,
            message: '长度在 1 到 32 个字符',
            trigger: 'blur'
          },
          {
            required: true,
            validator: isLoginNameExistRule,
            trigger: 'blur'
          }
        ],
        userName: [
          {
            required: true,
            message: '用户名称不能为空',
            trigger: 'blur'
          },
          {
            min: 1,
            max: 20,
            message: '长度在 1 到 32 个字符',
            trigger: 'blur'
          }
        ],
        selectedOrgId: [
          {
            required: true,
            message: '归属组织不能为空',
            trigger: 'blur'
          }
        ],
        password: [
          {
            required: true,
            message: '用户密码不能为空',
            trigger: 'blur'
          },
          {
            min: 6,
            max: 20,
            message: '长度在 6 到 20 个字符',
            trigger: 'blur'
          }
        ],
        email: [
          {
            type: 'email',
            message: '请输入正确的邮箱地址',
            trigger: ['blur', 'change']
          },
          {
            validator: isEmailExistRule,
            trigger: 'blur'
          }
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: '请输入正确的手机号码',
            trigger: 'blur'
          },
          {
            validator: isPhoneNumberExistRule,
            trigger: 'blur'
          }
        ]
      },
      exportUrl: ''
    }
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val)
    }
  },
  created() {
    this.getList()
    this.getTreeselect()
    this.getDicts('sys_user_status').then((response) => {
      this.statusOptions = response.data
    })
    this.getDicts('sys_user_sex').then((response) => {
      this.sexOptions = response.data
    })
    this.getConfigKey('zbiti.config.initPassword').then((response) => {
      this.initPassword = response.data || ''
    })
  },
  methods: {
    /** 选择组织节点 */
    selectOrgNode(node) {
      this.form.companyId = undefined
      this.form.deptId = undefined
      if (node.params['type'] === 'C') {
        this.form.companyId = node.params['companyId']
      } else if (node.params['type'] === 'D') {
        this.form.companyId = node.params['companyId']
        this.form.deptId = node.params['deptId']
      }
    },
    /** 查询用户列表 */
    getList: debounceWrapper(function () {
      this.loading = true
      console.log('查询按钮', this.queryParams)
      listPage(
        this.addDateRange(this.queryParams, ['updateTimeStart', 'updateTimeEnd'], this.dateRange)
      ).then((response) => {
        this.userList = response.data.list
        this.total = response.data.total
        this.loading = false
      })
    }),
    /** 查询部门下拉树结构 */
    getTreeselect: debounceWrapper(function () {
      //仅查询正常的机构
      orgTreeList().then((response) => {
        this.orgOptions = response.data
      })
    }),
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true
      return data.name.indexOf(value) !== -1
    },
    // 节点单击事件
    handleNodeClick: debounceWrapper(function (data) {
      this.queryParams.companyId = undefined
      this.queryParams.deptId = undefined
      console.log(data.params.type, data.params)
      if (data && data.params) {
        if (data.params['type'] === 'C') {
          this.queryParams.companyId = data.params['companyId']
        } else if (data.params['type'] === 'D') {
          this.queryParams.companyId = data.params['companyId']
          this.queryParams.deptId = data.params['deptId']
        }
      }
      // this.queryParams.parentId = data.parentId;
      this.getList()
    }),
    // 用户状态修改
    handleStatusChange: debounceWrapper(function (row) {
      let newStatus = row.status === '0' ? '1' : '0'
      let text = row.status === '0' ? '禁用' : row.status === '1' ? '启用' : '解锁'
      changeUserStatus(row.userId, newStatus)
        .then((response) => {
          if (response.data === true) {
            this.msgSuccess(text + '成功')
          } else {
            this.msgError(text + '失败')
          }
          this.getList()
        })
        .catch((e) => {
          console.error(e)
        })
    }),
    // 密码过期时间在七天内，显示为红色
    getExpiryStyle(updatePwdTime) {
      if (!updatePwdTime) {
        return {};
      }
      const expiryDate = new Date(updatePwdTime);
      const today = new Date();
      const sevenDaysLater = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000);

      if (expiryDate <= sevenDaysLater && expiryDate >= today) {
        return { color: 'red' }; // 密码在未来七天内到期，显示为红色
      } else {
        return {}; // 正常显示
      }
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        companyId: undefined,
        deptId: undefined,
        loginName: undefined,
        userName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: '0',
        remark: undefined,
        postIds: [],
        roleIds: []
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery: debounceWrapper(function () {
      this.queryParams.page = 1
      this.getList()
    }),
    /** 重置按钮操作 */
    resetQuery: debounceWrapper(function () {
      this.dateRange = []
      this.resetForm('queryForm')
      this.queryParams.companyId = undefined
      this.queryParams.deptId = undefined
      this.deptName = ''
      this.handleQuery()
    }),
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.userId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd: debounceWrapper(function () {
      this.reset()
      this.getTreeselect()
      getUser().then((response) => {
        this.postOptions = response.data.posts
        this.roleOptions = response.data.roles
        this.open = true
        this.title = '新增用户'
        this.form.password = this.initPassword
      })
    }),
    /** 修改按钮操作 */
    handleUpdate: debounceWrapper(function (row) {
      this.reset()
      this.getTreeselect()
      const userId = row.userId || this.ids[0]
      getUser(userId).then((response) => {
        this.form = response.data.userInfo
        this.postOptions = response.data.posts
        this.roleOptions = response.data.roles
        this.form.postIds = response.data.postIds
        this.form.roleIds = response.data.roleIds
        this.open = true
        this.title = '修改用户'
        this.form.password = ''
        if (this.form.deptId && this.form.deptId > 0) {
          this.form.selectedOrgId = 'D' + this.form.deptId
        } else {
          this.form.selectedOrgId = 'C' + this.form.companyId
        }
      })
    }),
    /** 重置密码按钮操作 */
    handleResetPwd: debounceWrapper(function (row) {
      this.$prompt('请输入"' + row.userName + '"的新密码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /.+/,
        inputErrorMessage: '密码不能为空',
        closeOnPressEscape: false,
        closeOnClickModal: false
      })
        .then(({ value }) => {
          if (value.trim().length > 0) {
            resetUserPwd(row.userId, row.loginName, value).then((response) => {
              if (response.data === 1) {
                this.msgSuccess('修改成功，新密码是：' + value)
              }
            })
          } else {
            this.msgError('新密码不能为空')
          }
        })
        .catch(() => {
        })
    }),
    /** 提交按钮 */
    submitForm: debounceWrapper(function () {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.userId != undefined) {
            updateUser(this.form).then((response) => {
              if (response.data === 1) {
                this.msgSuccess('修改成功')
                this.open = false
                this.getList()
              }
            })
          } else {
            addUser(this.form).then((response) => {
              if (response.data === 1) {
                this.msgSuccess('新增成功')
                this.open = false
                this.getList()
              }
            })
          }
        }
      })
    }),
    /** 删除按钮操作 */
    handleDelete: debounceWrapper(function (row) {
      const userIds = (row && row.userId) || this.ids.join(',')
      delUser(userIds)
        .then(() => {
          this.getList()
          this.msgSuccess('删除成功')
        })
        .catch(function () {})
    }),
    /** 导出按钮操作 */
    handleExport: debounceWrapper(function () {
      this.downloadUrl(
        '/system/user/export',
        this.addDateRange(this.queryParams, ['updateTimeStart', 'updateTimeEnd'], this.dateRange)
      )
    }),
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = '用户导入'
      this.upload.open = true
    },
    /** 下载模板操作 */
    handleImportTemplate: debounceWrapper(function () {
      this.downloadUrl('/system/user/downloadImportTemplate')
    }),
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess: debounceWrapper(function (response, file, fileList) {
      this.upload.open = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
      this.getList()
    }),
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit()
    },
    loadOptions(action, callback, parentNode) {
      /* empty */
    },
    showUserStatusText(scope) {
      var tips = '解锁时间: '
      if (scope.row.lockEndTime) {
        tips = tips + scope.row.lockEndTime
      } else {
        tips = tips + '永久锁定'
      }
      return tips
    }
  }
}
</script>
